package com.gensdai.leliang.activity;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.gensdai.leliang.BuildConfig;
import com.gensdai.leliang.Preferences.PreferencesActivity;
import com.gensdai.leliang.R;
import com.gensdai.leliang.base.BaseActivityNoAbs;
import com.gensdai.leliang.remoteInterface.URLConfig;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/6/5.
 */

public class Touch_we extends BaseActivityNoAbs implements View.OnClickListener, View.OnLongClickListener {

    @BindView(R.id.ui_title)
    TextView uiTitle;
    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.banben)
    TextView banben;
    @BindView(R.id.go_tuya)
    ImageView go_tuya;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.touch_we);
        ButterKnife.bind(this);
        init();
        setclick();
    }

    private void setclick() {
        back.setOnClickListener(this);
        banben.setOnLongClickListener(this);
        go_tuya.setOnLongClickListener(this);
    }

    /**
     * 初始化
     */
    private void init() {
        uiTitle.setText(getString(R.string.touch_we));
        try {
            banben.setText("当前版本：" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back:
                this.finish();
                break;
            default:
                break;
        }
    }

    @Override
    public boolean onLongClick(View v) {
        switch (v.getId()) {
            case R.id.banben:
                Toast.makeText(this, URLConfig.BASEURL, Toast.LENGTH_SHORT).show();

                if(BuildConfig.DEBUG)
                    startActivity(new Intent(this, PreferencesActivity.class));
                break;
            case R.id.go_tuya:
                if(BuildConfig.DEBUG)
                    startActivity(new Intent(this, tuya.class));
                break;
            default:
                break;
        }
        return false;
    }
}
